﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LEET.LEETCommon.Model;
using LEET.CommonInterfaces.TestControls;
using Compiled_Tests;
using System.Windows.Automation;
using LEET.LEETCommon.WidgetLookup;

namespace LEET.StandardModules.Instructions
{
    public class Focus : Instruction
    {
        private string element;
        
        public Focus(string[] args)
            : base(args)
        {
            element = args[1].Trim();
        }

        public static Focus apply(String[] args)
        {
            return new Focus(args);
        }

        public static IAutomationActionResult StaticCall()
        {
            //TODO
            return null;
        }

        public override String RenderStaticCall()
        {
            //TODO
            return "LEET.StandardModules.Instructions.Focus.StaticCall()";
        }

        public override string PlainText()
        {
            return "Focus set on the element \"" + element + "\"";
        }

        [Obsolete("This should now be replaced by RenderStaticCall", false)]
        protected override string MethodBody(CommonInterfaces.Compilers.AssertionSet asserts)
        {
            StringBuilder buf = new StringBuilder();
            buf.Append("                AutomationElement e = HierarchyFinder.GetElement(\"" + element + "\", Box.RootElement);\r\n");
            buf.Append("                ae.SetFocus();\r\n");
            buf.Append("                return new AutomationActionResult();\r\n");
            return buf.ToString();
        }

        [Obsolete("This should now be replaced by RenderStaticCall", false)]
        protected override string RenderedMethodName(int i)
        {
            return "_" + i + "_FOCUS" + "()";
        }
    }
}
